package foodserver;

import java.io.PrintWriter;
import java.util.ArrayList;


import javax.servlet.ServletException;


import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;

import org.json.JSONException;

import com.subway.babynote.syncdata.*;


import querysrc.query_addfeedback;
import querysrc.sqlConnectionHandler;
import querysrc.sqlConnectionHandlerManager;



import querysrc.*;
import serverdata.*;


public class ChangeUserInfo extends addbase{
	private static final long serialVersionUID = 1L;	
	query_change_user_birth_gender qa = null;	
	
	
	public ChangeUserInfo() {
		// TODO Auto-generated constructor stub
	}
	protected void initialize_subquery()
	{
		qa = new query_change_user_birth_gender(this.sqlconhandler);
	}
	protected void destory_subquery()
	{
		this.release_query(qa);
	}
	@Override
	protected JSONObject read_data(HttpServletRequest request) 
	{
		JSONObject jsono = null;
		try
		{
			String ur_str = request.getParameter(PostParam.last_avgRecord_Param.records);
			jsono = new JSONObject(ur_str);
			
		}
		catch(Exception ex)
		{
			
		}		
		// TODO Auto-generated method stub
		return jsono;
	}	
	protected int add_data(JSONObject input_jsono)
	{
		try
		 {		
			 int iret = 0;		
			 
			 ClientDataRecord.usersRecord ur = new ClientDataRecord.usersRecord(input_jsono);
			 
			 boolean bret = this.qau.sync_authen(ur.user_id, ur.imsi, ur.imei);
			 if(bret)
			 {
				 iret = qa.update_user_birth_gender(ur);
			 }
			 else
				 iret = errMessage.err_authenfail.errcode;
			 return iret;
		 }		 
		 catch (Exception e) {
			 System.out.println("FeedSync doPost error:" + e.getMessage());
		      e.printStackTrace();
		      return -1;
		    }
	}		 

	

}
